//
//  QDMessageTableViewCell.swift
//  QDMetroClient
//
//  Created by YueWen on 2019/2/24.
//  Copyright © 2019 YueWen. All rights reserved.
//

import UIKit

/// 展示信息的cell
final class QDMessageTableViewCell: NWTableViewCell {
    
    /// 图像
    let headerImageView = UIImageView()
    /// 公告信息
    let titleLabel = UILabel()
    /// 时间信息
    let timeLabel = UILabel()
    /// 红点信息
    let badgeLabel = UILabel()
    /// 副标题信息
    let subtitleLabel = UILabel()
    /// 方向标签
    let arrowImageView = UIImageView()
    
    override func buildView() {
        super.buildView()
        
        headerImageView.backgroundColor = .white
        
        badgeLabel.backgroundColor = #colorLiteral(red: 0.9803921569, green: 0.3137254902, blue: 0.3176470588, alpha: 1)
        badgeLabel.textAlignment = .center
        badgeLabel.font = Font.semibold.font(size: 9)
        badgeLabel.textColor = .white
        badgeLabel.text = "1"
        badgeLabel.layer.cornerRadius = 7
        badgeLabel.clipsToBounds = true
        
        titleLabel.textColor = QDColors.separator
        titleLabel.font = Font.semibold.font(size: 16)
        titleLabel.text = "公告信息"
        
        timeLabel.textColor = QDColors.gray
        timeLabel.font = Font.regular.font(size: 12)
        timeLabel.text = "2019-01-01  12:12"
        
        subtitleLabel.textColor = QDColors.separator
        subtitleLabel.font = Font.light.font(size: 14)
        subtitleLabel.text = "青岛地铁运营信息：目前13号线进入打算打算大大萨达"
        
        arrowImageView.image = "mes_arr_right".namedImage
        
        contentView.addSubview(headerImageView)
        contentView.addSubview(titleLabel)
        contentView.addSubview(badgeLabel)
        contentView.addSubview(timeLabel)
        contentView.addSubview(subtitleLabel)
        contentView.addSubview(arrowImageView)
        
        headerImageView.snp.makeConstraints { (make) in
            make.height.width.equalTo(48)
            make.left.equalToSuperview().offset(20)
            make.top.equalToSuperview().offset(16)
        }
        
        badgeLabel.snp.makeConstraints { (make) in
            make.width.height.equalTo(14)
            make.top.equalToSuperview().offset(11)
            make.left.equalToSuperview().offset(61)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(84)
            make.top.equalTo(15.5)
            make.height.equalTo(22)
        }
        
        timeLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().inset(56)
            make.height.equalTo(17)
            make.centerY.equalTo(titleLabel)
        }
        
        subtitleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp.bottom).offset(5)
            make.right.equalToSuperview().inset(50)
            make.height.equalTo(20)
        }
        
        arrowImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(16)
            make.right.equalToSuperview().inset(17)
            make.centerY.equalToSuperview()
        }
    }
}
